import service from './request.js'

/*
失败接口
/api/users/login?apifoxResponseId=573659891

*/
// 登录接口
function loginApi(data){
	return service({
		url:'/api/users/login',
		method:'post',
		data:data
	})
}

// 注册接口
function registerApi(data){
	return service({
		url:'/api/users/register',
		method:'post',
		data:data
	})
}

//获取文章列表(按浏览量查询)
function getArticleList_sortByViewsApi(){
	return service({
		url:'/api/articles/sortByViews',
		method:'get'
	})
}
// 获取文章列表(按发布时间查询)
function getArticleList_sortByTimeApi(){
	return service({
		url:'/api/articles/sortByTime',
		method:'get'
	})
}

//查看文章(修改过)
function getArticleByIdApi(data){
	return service({
		url:'/api/articles/getById',
		method:'post',
		data:data
	})
}
// 模糊搜索文章只对标题模糊搜索，根据type选择查找公告、任务或文章)
function searchArticleApi(data){
	return service({
		url:'/api/articles/searchArticle',
		method:'post',
		data:data
	})
}

// 添加评论
function addCommentApi(data){
	return service({
		url:'/api/comments/add',
		method:'post',
		data:data
	})
}
// 评论点赞
function addCommentLikeApi(data){
	return service({
		url:'/api/comments/likeComment',
		method:'post',
		data:data
	})
}

// 点赞文章
function addArticleLikeApi(data){
	return service({
		url:'/api/articles/likeArticle',
		method:'post',
		data:data
	})
}

//获取用户文章列表(按最新发布查询)
function getUserArticleListApi(data){
	return service({
		url:'/api/articles/byUser',
		method:'get',
		params:data
	})
}
//获取用户任务列表(按最新发布查询)
function getUserTaskListApi(data){
	return service({
		url:'/api/articles/byUserTasks',
		method:'post',
		data:data
	})
}

//上传图片
function uploadImgApi(data){
	return service({
		url:'/api/res/upload',
		method:'post',
		data:data
	})
}
// 首次编辑文章，获取文章id
// /api/articles/getNewId
function getNewArticleIdApi(data){
	return service({
		url:'/api/articles/getNewId',
		method:'post',
		data:data
	})
}
// 最终上传文章内容
// /api/articles/commit
function commitArticleApi(data){
	return service({
		url:'/api/articles/commit',
		method:'post',
		data:data
	})
}

//修改用户头像
// /api/res/avatar
function modifyAvatarApi(data){
	return service({
		url:'/api/res/avatar',
		method:'post',
		data:data
	})
}

//查看用户详情
// /api/users/userinfo
function getUserInfoApi(data){
	return service({
		url:'/api/users/userinfo',
		method:'post',
		data:data
	})
}
// 保护用户信息/api/users/updateInfo
function saveUserInfoApi(data){
	return service({
		url:'/api/users/updateInfo',
		method:'post',
		data:data
	})
}

// 修改密码/api/users/updatePwd
function modifyPwdApi(data){
	return service({
		url:'/api/users/updatePwd',
		method:'post',
		data:data
	})
}

// 退出登录/api/users/logout
function logoutApi(data){
	return service({
		url:'/api/users/logout',
		method:'post',
		data:data
	})
}
// 查看自身发布的文章、公告(根据type)/api/articles/searchSelf
function searchSelfArticleApi(data){
	return service({
		url:'/api/articles/searchSelf',
		method:'get',
		params:data
	})
}

// 查看自身发布的任务/api/articles/searchSelfMission
function searchSelfMissionApi(data){
	return service({
		url:'/api/articles/searchSelfMission',
		method:'get',
		params:data
	})
}

//删除文章/api/articles/delete
function deleteArticleApi(data){
	return service({
		url:'/api/articles/delete',
		method:'post',
		data:data
	})
}
// 设置任务为“已领取”/api/articles/ack
function ackMissionApi(data){
	return service({
		url:'/api/articles/ack',
		method:'post',
		data:data
	})
}
// /api/articles/notices获取公告列表
function getNoticeListApi(data){
	return service({
		url:'/api/articles/notices',
		method:'get',
		params:data
	})
}
//取消点赞文章/api/articles/cancelLikeArticle
function cancelArticleLikeApi(data){
	return service({
		url:'/api/articles/cancelLikeArticle',
		method:'post',
		data:data
	})
}
// 取消评论点赞/api/comments/cancelLikeComment
function cancelCommentLikeApi(data){
	return service({
		url:'/api/comments/cancelLikeComment',
		method:'post',
		data:data
	})
}

// 获取任务列表/api/articles/tasks
function getMissionListApi(data){
	return service({
		url:'/api/articles/tasks',
		method:'get',
		params:data
	})
}
export default{
	loginApi,
	registerApi,
	getUserArticleListApi,
	getArticleList_sortByViewsApi,
	getArticleList_sortByTimeApi,
	getArticleByIdApi,
	searchArticleApi,
	addCommentApi,
	addCommentLikeApi,
	addArticleLikeApi,
	getUserTaskListApi,
	uploadImgApi,
	getNewArticleIdApi,
	commitArticleApi,
	modifyAvatarApi,
	getUserInfoApi,
	saveUserInfoApi,
	modifyPwdApi,
	logoutApi,
	searchSelfArticleApi,
	searchSelfMissionApi,
	deleteArticleApi,
	ackMissionApi,
	getNoticeListApi,
	cancelArticleLikeApi,
	cancelCommentLikeApi,
	getMissionListApi
}